<?php
$app_config = require(dirname(__FILE__) . '/../config/boot.php');
require $app_config['QEEPHP_DIR'] . '/library/q.php';
require $app_config['APP_DIR'] . '/myapp.php';
$ret = MyApp::instance($app_config);
$headers = apache_request_headers();
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($headers['BSS-API-TIMESTAMP']) && isset($headers['BSS-API-CERT']))
{
	if (abs($headers['BSS-API-TIMESTAMP'] - CURRENT_TIMESTAMP) < 900)
	{
		if ($headers['BSS-API-CERT'] == md5($headers['BSS-API-TIMESTAMP'] . Q::ini('custom_api/news_api_cert')))
		{
			if (isset($_POST['title']) && isset($_POST['content']))
			{
				$news = array('title' => $_POST['title'], 'content' => $_POST['content']);
				$result = News::create($news);
				echo json_encode($result);exit;
			}
		}
	}
}
echo json_encode(array('ack' => FAILURE, 'message' => '验证出错或不符合规则'));exit;